<?php
$basedir = dirname(__FILE__);
require_once $basedir . '/../classes/minime.php';
MiniMe::initialize();

if( count($argv) != 3) {
      echo "\n\tERROR!";
      echo "\n\t\tPlease provide USERNAME ID-TO-BE-DELETED as parameters to this function.";
      echo "\n\n\tExample:";
      echo "\n\t\t" . 'php entry.php koski "tag:2136516984:hhdd:235678"';
      echo "\n\n";
      exit;
}

$username = $argv[1];
$id      = $argv[2];

$userLoader = new Minime_User_Loader(Minime::$conf);
$user = $userLoader->getUser($username);

if(!$user) {
    echo "\n\t\tDude, the username you want to delte a blog post does not exists.";
    echo "\n\n";
    exit;
}

$atomLoader = new Minime_Atom_Loader(MiniMe::$conf);
$feed = $atomLoader->getFeed($username);

$feed->removeEntry($id);
$feed->updateUpdated();

$atomStorer = new Minime_Atom_Storer(MiniMe::$conf);
$atomStorer->storeAtom($username, $feed);

echo "\n\n\tDONE!\n";
